#! /usr/bin/env python
# -*- coding: utf-8 -*-

from ConfigParser import SafeConfigParser
from Pacx import *
import getopt
import os
import shutil
import subprocess
import sys
import time
import traceback


import urllib

def filter_non_printable(str):
  return ''.join([c for c in str if ord(c) > 31 or ord(c) == 9])

s =  "  sdfsdf   sdf      "
print s.strip()


class Ubu(Pacx):
    
    def __init__(self):
        Pacx.__init__(self)

    def setPackageState(self, pkg, dateField, state, error):
        now = time.strftime(self.date_format)      
        error = error.replace("'", "\\'")
        query = "update PACKAGE_QUEUE SET state='%s', %s='%s', error='%s' where package='%s' and action='extraction'" % (state, dateField, now, error, pkg)
        
        print "setPackageState... %s" % query
        cursor = self.db.cursor()
        result = cursor.execute(query)
        self.log("Set package state query result: %s" % result)
        cursor.close()

def main():
#    exx = Ubu()
#    error = "OSError: [Errno 1] Operation not permitted: '/home/doc4/data/370/terminal-server2-1.5-11mdv2009.0.noarch.rpm/var/lib/terminal-server/common/var/lib/gdm'"
#    try:
#        result = exx.setPackageState("terminal-server2-1.5-11mdv2009.0.noarch.rpm","start_date","extraction", error)
#    except Exception,e:
#        print str(e)
#        
#    exx.db.close()
    print "yo"

pacx = Pacx()
s = "psi-0.12.1-1mdv2009.1.src.rpm"
o = pacx.string_to_integer(s)
print o


if __name__ == "__main__":
    main()




#s = "Nicolas L�cu£££££mlskdjf￦ﾝmkljsqdf@@@@reuil &lt;qsqmlkdfjqkjqfdmsééè%$$$"
#
#st = filter_non_printable(s)
#print st
#
#
#f = urllib.urlopen("http://doc4.mandriva.org/bin/view/testcloud/vdis?xpage=plain")
#vdis = eval(f.read())
#for vdi in vdis:
#    print "%s %s" % (vdi[0], vdi[1])
